#
# (C) COPYRIGHT 2017 ARM Limited. All rights reserved.
#
# This program is free software and is provided to you under the terms of the
# GNU General Public License version 2 as published by the Free Software
# Foundation, and any use by you of this program is subject to the terms
# of such GNU licence.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, you can access it online at
# http://www.gnu.org/licenses/gpl-2.0.html.
#
# SPDX-License-Identifier: GPL-2.0
#
#


import os
import re
Import('env')

if env['v'] != '1':
	env['MAKECOMSTR'] = '[MAKE] ${SOURCE.dir}'

src = [ Glob('#kernel/drivers/base/smc_protected_mode_switcher/*.c'),
		Glob('#kernel/drivers/base/smc_protected_mode_switcher/*.S'),
		Glob('#kernel/drivers/base/smc_protected_mode_switcher/*.h'),
		Glob('#kernel/drivers/base/smc_protected_mode_switcher/K*'),
		Glob('#kernel/drivers/base/smc_protected_mode_switcher/Makefile') ]

env.Append( CPPPATH = '#kernel/include' )
env['smc_protected_mode_switcher'] = 1

if env.GetOption('clean') :
	# Clean module
	env.Execute(Action("make clean", '[CLEAN] smc_protected_mode_switcher'))
	cmd = env.Command('$STATIC_LIB_PATH/smc_protected_mode_switcher.ko', src, [])
	env.ProgTarget('smc_protected_mode_switcher', cmd)
else:
	# Build module
	makeAction=Action("cd ${SOURCE.dir} && make && cp smc_protected_mode_switcher.ko $STATIC_LIB_PATH/", '$MAKECOMSTR')
	cmd = env.Command('$STATIC_LIB_PATH/smc_protected_mode_switcher.ko', src, [makeAction])
	env.ProgTarget('smc_protected_mode_switcher', cmd)

